//
//  TodayConsultCell.m
//  Doctor
//
//  Created by 阳光 on 16/9/8.
//  Copyright © 2016年 阳光. All rights reserved.
//  今日咨询

#import "TodayConsultCell.h"

@interface TodayConsultCell ()

@property(nonatomic,strong)UIView *bgView;

// 患者头像
@property(nonatomic,strong)UIImageView *imgURL;

// 患者名字
@property(nonatomic,strong)UILabel *nameLabel;

// 患者发的信息时间
@property(nonatomic,strong)UILabel *timeLabel;

// 患者发的信息
@property(nonatomic,strong)UILabel *detailLabel;


@property(nonatomic,strong)UIView *redView;


@end

@implementation TodayConsultCell

-(instancetype)initWithStyle:(UITableViewCellStyle)style reuseIdentifier:(NSString *)reuseIdentifier
{
    self=[super initWithStyle:style reuseIdentifier:reuseIdentifier];
    if (self) {
        self.backgroundColor=MAIN_BACK_COLOR;
        self.bgView.hidden=NO;
        self.imgURL.hidden=NO;
        _imgURL.image=[UIImage imageNamed:@"logo"];
        self.nameLabel.font=Font_Number(17);
        self.timeLabel.font=Font_Number(13);
        self.detailLabel.font=Font_Number(14);
        self.redView.hidden=NO;
    }
    return self;
}


-(UIView *)bgView
{
    if (_bgView==nil) {
        _bgView=[UIView new];
        [self.contentView addSubview:_bgView];
        ViewBorderRadius(_bgView,kmargin/2,2,ClearColor);
        [_bgView mas_makeConstraints:^(MASConstraintMaker *make) {
            make.left.top.mas_equalTo(kmargin);
            make.right.bottom.mas_equalTo(-kmargin);
        }];
        _bgView.backgroundColor=WhiteColor;
    }
    return _bgView;
}


// imgURL
-(UIImageView *)imgURL
{
    if (!_imgURL) {
        _imgURL=[[UIImageView alloc]init];
        [_bgView addSubview:_imgURL];
        // 圆角和边框
        ViewBorderRadius(_imgURL,kmargin*5/2,1,ClearColor);
        [_imgURL mas_makeConstraints:^(MASConstraintMaker *make) {
            make.left.mas_equalTo(kmargin);
            make.top.mas_equalTo(self.bgView.mas_top).offset(kmargin);
            make.size.mas_equalTo(CGSizeMake(kmargin*5,kmargin*5));
        }];
    }
    return _imgURL;
}


// nameLabel
- (UILabel *)nameLabel
{
    if (!_nameLabel) {
        _nameLabel=[self getLabelWithText:@"赵启平" font:Font_Number(17) textColor:Color000000 textAlignment:NSTextAlignmentLeft lineBreakMode:NSLineBreakByCharWrapping numberOfLines:1];
        [_bgView addSubview:_nameLabel];
        [_nameLabel mas_makeConstraints:^(MASConstraintMaker *make) {
            make.left.mas_equalTo(self.imgURL.mas_right).offset(kmargin/2);
            make.top.mas_equalTo(self.imgURL.mas_top);
        }];
    }
    return _nameLabel;
}

// timeLabel
- (UILabel *)timeLabel
{
    if (!_timeLabel) {
        _timeLabel=[self getLabelWithText:@"2016.9.10" font:Font_Number(13) textColor:ColorBDBDBD textAlignment:NSTextAlignmentLeft lineBreakMode:NSLineBreakByCharWrapping numberOfLines:1];
        [_bgView addSubview:_timeLabel];
        [_timeLabel mas_makeConstraints:^(MASConstraintMaker *make) {
            make.left.mas_equalTo(self.nameLabel.mas_right).offset(kmargin/2);
            make.right.mas_equalTo(-kmargin);
            make.top.mas_equalTo(self.nameLabel.mas_top);
        }];
    }
    return _timeLabel;
}


// detailLabel
- (UILabel *)detailLabel
{
    if (!_detailLabel) {
        _detailLabel=[self getLabelWithText:@"我有个问题想咨询您下。。。" font:Font_Number(14) textColor:Color666666 textAlignment:NSTextAlignmentLeft lineBreakMode:NSLineBreakByCharWrapping numberOfLines:1];
        [_bgView addSubview:_detailLabel];
        [_detailLabel mas_makeConstraints:^(MASConstraintMaker *make) {
            make.left.mas_equalTo(self.imgURL.mas_right).offset(kmargin/2);
            make.top.mas_equalTo(self.nameLabel.mas_bottom);
        }];
    }
    return _detailLabel;
}

-(UIView *)redView
{
    if (!_redView) {
        _redView=[UIView new];
        ViewBorderRadius(_redView,kmargin/2,1,ClearColor);
        _redView.backgroundColor=ColorFF5D71;
        [_bgView addSubview:_redView];
        [_redView mas_makeConstraints:^(MASConstraintMaker *make) {
            make.right.mas_equalTo(-kmargin);
            make.size.mas_equalTo(CGSizeMake(kmargin,kmargin));
            make.centerY.mas_equalTo(self.detailLabel.mas_centerY);
        }];
    }
    return _redView;
}

@end
